package com.heima.Thread;


public class ThreadTest {
    public static void main(String[] args) {
        //调用第一种thread方式
        MyThread myThread=new MyThread();
        myThread.setName("thread1_");
        myThread.start();

        MyThread myThread2=new MyThread();
        myThread2.setName("thread2_");
        myThread2.start();//启动线程


        //调用第二种实现Runnable接口
        MyRunnable myRunnable=new MyRunnable();
        Thread thread=new Thread(myRunnable);
        thread.setName("runnable1_");
        thread.start();

        Thread thread2=new Thread(myRunnable);
        thread2.setName("runnable2_");
        thread2.start();
    }

    /**
     * 定义创建线程Thread方式
     */
    public static class MyThread extends Thread{
        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + "--" +System.currentTimeMillis());
        }
    }

    /**
     * 定义创建线程实现Runnable方式
     */
    public static  class MyRunnable implements Runnable{
        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName()+"--"+System.currentTimeMillis());
        }
    }
}
